/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package restauranteaplicacion.Ingresos;
import Clases.Observador;
import java.util.Calendar;
import CapaNegocios.CNMesas;
import CapaNegocios.CNUsuarios;
import Clases.ComboBox;
import entidad.Mesa;
import entidad.Orden;
import entidad.Usuarios;
import java.util.List;
import CapaNegocios.CNOrden;
import Clases.OrdenesMesas;
import Clases.Parametros;
import entidad.Deuda;
import java.util.ArrayList;
import javax.swing.JOptionPane;
/**
 *
 * @author Victor
 */
public class IngresoPagos extends javax.swing.JInternalFrame {

    /**
     * Creates new form IngresoProducto
     */
    Observador obs;
    OrdenesMesas orden;
    boolean modificable;
    public IngresoPagos() {
        initComponents();
        fecha.setDate(Calendar.getInstance().getTime());
         //Combo Box de Meseros 
       cargarMesas();
       //Combo Box de Otros
       cargarUsuarios();
       obs= null;
       txtOrden.setText(Integer.toString(CNOrden.regresarNumeroOrde()));
       modificable=false;
    }
    
    public IngresoPagos(Observador obs)
    {
        initComponents();
        fecha.setDate(Calendar.getInstance().getTime());
         //Combo Box de Meseros 
       cargarMesas();
       //Combo Box de Otros
       cargarUsuarios();
       this.obs= obs;
       txtOrden.setText(Integer.toString(CNOrden.regresarNumeroOrde()));
       modificable=false;
    }
    
    public IngresoPagos(Observador obs, int indexLista) {
        initComponents();
        fecha.setDate(Calendar.getInstance().getTime());
        this.obs= obs;
        this.closable = false;
        cargarMesas();
        cargarUsuarios();
        orden = Comandas.listaOrden.get(indexLista);
        Mesa mesa = orden.getMesa();
        cmbMesa.setSelectedItem(new ComboBox (mesa.getIdMesa(), String.valueOf(mesa.getNumeroMesa())));
        Usuarios usuario = orden.getUsuario();
        if(usuario!=null)
            cmbMesero.setSelectedItem(new Clases.ComboBox(usuario.getIdUsuarios(), usuario.getUserName()));
        else
            cmbMesero.setSelectedIndex(-1);
       txtPagar.setText(orden.total().toString());
       txtPagar.setEditable(false);       
       cmbMesa.setEnabled(false);
       txtOrden.setText(Integer.toString(CNOrden.regresarNumeroOrde()));
       modificable=false;
       if(orden.getOrden()!=null)
       {
           //orden1.setIdOrden(orden.getOrden().getIdOrden());
           orden1=orden.getOrden();
           txtOrden.setText(Integer.toString(orden.getOrden().getNoOrden()));
           modificable=true;
       }
       int y=0;
       if(jCheckBox2.isSelected())
        {
            float x= Float.parseFloat(txtPagar.getText());
            y=(int) (x*0.05);
            txtPropina.setText(String.valueOf(y));
        }
       float total = Float.valueOf(txtPagar.getText());
        lbTotal.setText(String.valueOf(total+y));
       //cmbMesero.setEnabled(false);
       
    }

    private void cargarMesas()
    {
        List<Mesa> lista = CNMesas.buscarTodos();
        if(lista != null)
        for(Mesa mes : lista)
            cmbMesa.addItem(new ComboBox(mes.getIdMesa(), String.valueOf(mes.getNumeroMesa())));
    }
    
    private void cargarUsuarios()
    {
        List<Usuarios> listaUsuairo = CNUsuarios.buscarActivos();//CNUsuarios.buscarMeseros(1);
       if(listaUsuairo != null)
        for(Usuarios us : listaUsuairo)
            cmbMesero.addItem(new Clases.ComboBox(us.getIdUsuarios(), us.getUserName()));
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        orden1 = new entidad.Orden();
        jPanel1 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        btnCancelar = new javax.swing.JButton();
        btnGuardar = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtEfectivo = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txtTarjeta = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtPropina = new javax.swing.JTextField();
        txtDescuento = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        lbTotal = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        lbVuelto = new javax.swing.JLabel();
        txtVoucher = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        label = new javax.swing.JLabel();
        lbPagado = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        fecha = new com.toedter.calendar.JDateChooser();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtOrden = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        cmbMesa = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        cmbMesero = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        txtPagar = new javax.swing.JTextField();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox2 = new javax.swing.JCheckBox();

        orden1.setActivo(java.lang.Boolean.TRUE);
        orden1.setDescuento(new java.lang.Float(0.0F));
        orden1.setGranTotal(new java.lang.Float(0.0F));
        orden1.setMinutosEspera(new java.lang.Integer(0));
        orden1.setPagado(java.lang.Boolean.FALSE);
        orden1.setPropinaTarjeta(new java.lang.Float(0.0F));
        orden1.setTotal(new java.lang.Float(0.0F));
        orden1.setTotalEfectivo(new java.lang.Float(0.0F));
        orden1.setTotalTarjeta(new java.lang.Float(0.0F));

        setClosable(true);
        setIconifiable(true);
        setMaximumSize(new java.awt.Dimension(666, 473));
        setMinimumSize(new java.awt.Dimension(666, 450));
        setPreferredSize(new java.awt.Dimension(666, 473));
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosing(evt);
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
        });
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.PAGE_AXIS));

        jPanel1.setBackground(new java.awt.Color(54, 149, 240));
        jPanel1.setMaximumSize(new java.awt.Dimension(650, 50));
        jPanel1.setMinimumSize(new java.awt.Dimension(500, 50));
        jPanel1.setPreferredSize(new java.awt.Dimension(650, 50));

        jLabel5.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Pagos");
        jPanel1.add(jLabel5);

        getContentPane().add(jPanel1);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        btnCancelar.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/restauranteaplicacion/Ingresos/circle-x-3x.png"))); // NOI18N
        btnCancelar.setText("Salir");
        btnCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCancelar.setPreferredSize(new java.awt.Dimension(85, 53));
        btnCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnGuardar.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/circle-check-3x.png"))); // NOI18N
        btnGuardar.setText("Guardar");
        btnGuardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnGuardar.setNextFocusableComponent(fecha);
        btnGuardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel3.setMaximumSize(new java.awt.Dimension(266, 235));
        jPanel3.setMinimumSize(new java.awt.Dimension(308, 241));

        jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel1.setText("Pago Efectivo");

        txtEfectivo.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N
        txtEfectivo.setMaximumSize(new java.awt.Dimension(6, 21));
        txtEfectivo.setNextFocusableComponent(txtTarjeta);
        txtEfectivo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtEfectivoFocusGained(evt);
            }
        });
        txtEfectivo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtEfectivoKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtEfectivoKeyTyped(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel3.setText("Pago Tarjeta");

        txtTarjeta.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N
        txtTarjeta.setMaximumSize(new java.awt.Dimension(6, 21));
        txtTarjeta.setNextFocusableComponent(txtPropina);
        txtTarjeta.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtTarjetaFocusGained(evt);
            }
        });
        txtTarjeta.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtTarjetaKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtTarjetaKeyTyped(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel2.setText("Propina ");

        txtPropina.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N
        txtPropina.setMaximumSize(new java.awt.Dimension(6, 21));
        txtPropina.setNextFocusableComponent(txtDescuento);
        txtPropina.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtPropinaFocusGained(evt);
            }
        });
        txtPropina.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtPropinaKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtPropinaKeyTyped(evt);
            }
        });

        txtDescuento.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N
        txtDescuento.setMaximumSize(new java.awt.Dimension(6, 21));
        txtDescuento.setNextFocusableComponent(txtVoucher);

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, orden1, org.jdesktop.beansbinding.ELProperty.create("${descuento}"), txtDescuento, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        txtDescuento.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtDescuentoFocusGained(evt);
            }
        });
        txtDescuento.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtDescuentoKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDescuentoKeyTyped(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel4.setText("Descuento");

        jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel6.setText("Total a Pagar");

        lbTotal.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        lbTotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

        jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel7.setText("Vuelto");

        lbVuelto.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        lbVuelto.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lbVuelto.setText("0.00");

        txtVoucher.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N
        txtVoucher.setMaximumSize(new java.awt.Dimension(6, 21));
        txtVoucher.setNextFocusableComponent(btnGuardar);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, orden1, org.jdesktop.beansbinding.ELProperty.create("${noVoucherTarjeta}"), txtVoucher, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        txtVoucher.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtVoucherKeyTyped(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel10.setText("No Voucher");

        label.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        label.setText("Pagado");

        lbPagado.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        lbPagado.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lbPagado.setText("0.00");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(40, 191, Short.MAX_VALUE)
                .addComponent(lbTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(42, 42, 42))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addComponent(jLabel1))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(40, 40, 40)
                                .addComponent(jLabel4))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(34, 34, 34)
                                .addComponent(jLabel10))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(26, 26, 26)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel2))))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txtDescuento, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)
                            .addComponent(txtPropina, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtTarjeta, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtEfectivo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtVoucher, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addComponent(jLabel6)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lbVuelto, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(label)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lbPagado, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel1))
                    .addComponent(txtEfectivo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel3))
                    .addComponent(txtTarjeta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPropina, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel4))
                    .addComponent(txtDescuento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(txtVoucher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(lbVuelto)
                    .addComponent(label)
                    .addComponent(lbPagado))
                .addGap(11, 11, 11)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbTotal))
                .addGap(11, 11, 11))
        );

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        fecha.setNextFocusableComponent(txtOrden);

        jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel8.setText("Fecha");

        jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel9.setText("No Orden");

        txtOrden.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N
        txtOrden.setNextFocusableComponent(txtPagar);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, orden1, org.jdesktop.beansbinding.ELProperty.create("${noOrden}"), txtOrden, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        txtOrden.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtOrdenKeyTyped(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel11.setText("Mesa");

        cmbMesa.setNextFocusableComponent(txtEfectivo);

        jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel12.setText("Mesero");

        cmbMesero.setNextFocusableComponent(cmbMesa);

        jLabel13.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel13.setText("Total pagar");

        txtPagar.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N
        txtPagar.setNextFocusableComponent(cmbMesero);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, orden1, org.jdesktop.beansbinding.ELProperty.create("${total}"), txtPagar, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        txtPagar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtPagarKeyTyped(evt);
            }
        });

        jCheckBox1.setText("<html>Descuento Total</html>");

        jCheckBox2.setSelected(true);
        jCheckBox2.setText("<html>Propina Incluida</html>");
        jCheckBox2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCheckBox2ItemStateChanged(evt);
            }
        });
        jCheckBox2.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox2StateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(114, 114, 114)
                        .addComponent(fecha, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtOrden, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cmbMesero, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cmbMesa, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jCheckBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(txtPagar, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)))))))
                .addGap(32, 32, 32))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(fecha, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtOrden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addGap(25, 25, 25)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPagar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBox1)
                    .addComponent(jCheckBox2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(cmbMesero, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(cmbMesa, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(74, 74, 74)
                .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 311, Short.MAX_VALUE)
                .addComponent(btnGuardar)
                .addGap(95, 95, 95))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(14, 14, 14))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnGuardar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(44, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel2);

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private float convertidor(String numero)
    {
        float num=0;
        try {
            num = Float.parseFloat(numero);
         } catch (NumberFormatException e) {
             return 0;
         }
        return num;
    }
    
    private boolean validacionDatos()
    {
        boolean var = true;
        float efectivo= convertidor(txtEfectivo.getText());
        float tarjeta =  convertidor(txtTarjeta.getText().toString());
        float vuelto =convertidor(lbVuelto.getText());
        float propinaTarjeta = convertidor(txtPropina.getText());
        float descuento = convertidor(txtDescuento.getText());
        float pagar= convertidor(txtPagar.getText());
        if((tarjeta-propinaTarjeta) >pagar || descuento > pagar )
            return false;
        //orden1.setTotal(orden1.getTotal+pagar);
        if(efectivo>0)
        {
            orden1.setTotalEfectivo(orden1.getTotalEfectivo()+efectivo-vuelto-propinaTarjeta );
            orden1.setGranTotal(orden1.getGranTotal()+efectivo+tarjeta -vuelto-propinaTarjeta);
            orden1.setTotalTarjeta(orden1.getTotalTarjeta()+tarjeta);
        }
        else
        {
            orden1.setTotalEfectivo(orden1.getTotalEfectivo() );
            orden1.setGranTotal(orden1.getGranTotal()+tarjeta -propinaTarjeta);
            orden1.setTotalTarjeta(orden1.getTotalTarjeta()+tarjeta-propinaTarjeta);        
        }
        if(descuento>0)
        {
            if(orden1.getTotal()==descuento)
             {
                orden1.setTotal(pagar-orden1.getGranTotal()-descuento); 
                orden1.setGranTotal(Float.valueOf("0"));
            }
            else
            {
                orden1.setTotal(orden1.getTotal()-descuento);
                //orden1.setGranTotal(orden1.getGranTotal()-descuento); 
            }
           
        }
       else
            orden1.setTotal(orden1.getTotal()+pagar-orden1.getGranTotal());   
        
        orden1.setPropinaTarjeta(orden1.getPropinaTarjeta()+propinaTarjeta);
        orden1.setDescuento(orden1.getDescuento()+descuento);
        
        return var;
    }
    
    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
        // TODO add your handling code here: 
        Orden temporalActivo = CNOrden.buscarId(orden1.getIdOrden());
        orden1.setActivo(temporalActivo.getActivo());
        if(cmbMesero.getSelectedIndex()==-1)
        {
          JOptionPane.showMessageDialog(this, "No ha ingresado el usuario Correcto", "Error", JOptionPane.ERROR_MESSAGE);
           return;  
        }
        if(!validacionDatos())
        {
           JOptionPane.showMessageDialog(this, "Parametros incorretos", "Error", JOptionPane.ERROR_MESSAGE);
           return;
        }
        if(obs == null)
        {
            try{
                Mesa mesa = CNMesas.buscarId(((ComboBox)cmbMesa.getSelectedItem()).getId());
                Usuarios us  = CNUsuarios.buscarId(((ComboBox)cmbMesero.getSelectedItem()).getId());                
                orden1.setFecha(fecha.getDate());
                //orden1.setTotalEfectivo(Float.valueOf(txtEfectivo.getText())-Float.valueOf(lbVuelto.getText()));
                orden1.setMesaidMesa(mesa);
                //orden1.setActivo(false);
                orden1.setUsuarioidUsuario(us);
                if(CNOrden.modificar(orden1))
                    JOptionPane.showMessageDialog(this, "Se a Guardado Correctamente", "Informacion", JOptionPane.INFORMATION_MESSAGE);
                else
                    JOptionPane.showMessageDialog(this, "Parametros incorretos", "Error", JOptionPane.ERROR_MESSAGE); 
                limpiar();
                txtOrden.setText(Integer.toString(CNOrden.regresarNumeroOrde()));
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(this, "Parametros incorretos", "Error", JOptionPane.ERROR_MESSAGE);
            }
            
        }
        else
        {
            Mesa mesa = CNMesas.buscarId(((ComboBox)cmbMesa.getSelectedItem()).getId());
            Usuarios us  = CNUsuarios.buscarId(((ComboBox)cmbMesero.getSelectedItem()).getId());
            orden1.setFecha(fecha.getDate());
            //orden1.setTotalEfectivo(Float.valueOf(txtEfectivo.getText())-Float.valueOf(lbVuelto.getText()));
            //orden1.setActivo(false);
            orden1.setMesaidMesa(mesa);
            orden1.setUsuarioidUsuario(us);
            orden1.setDetalleordenCollection(orden.regresarDetalleOrdenes());
            if(modificable)
            {
                orden1.setDeudaCollection(new ArrayList<Deuda>());
                if(CNOrden.modificar(orden1))
                {
                    JOptionPane.showMessageDialog(this, "Se a Guardado Correctamente", "Informacion", JOptionPane.INFORMATION_MESSAGE);
                    orden.limpiar(orden1.getGranTotal(),orden1.getDescuento());
                    orden.setOrden(orden1);
                    obs.actualizar();                
                    this.setVisible(false);
                }                
                else
                {
                    JOptionPane.showMessageDialog(this, "Parametros incorretos", "Error", JOptionPane.ERROR_MESSAGE); 
                    return;
                }
            }
            else if(CNOrden.modificar(orden1))
            {
                JOptionPane.showMessageDialog(this, "Se a Guardado Correctamente", "Informacion", JOptionPane.INFORMATION_MESSAGE);
                orden.limpiar(orden1.getGranTotal(),orden1.getDescuento());
                orden.setOrden(orden1);
                obs.actualizar();                
                this.setVisible(false);
            }                
            else
                    JOptionPane.showMessageDialog(this, "Parametros incorretos", "Error", JOptionPane.ERROR_MESSAGE); 
            
        }
        
    }//GEN-LAST:event_btnGuardarActionPerformed

    private void limpiar()
    {
        txtDescuento.setText("");
        txtPagar.setText("");
        txtPropina.setText("");
        txtVoucher.setText("");       
        txtEfectivo.setText("");
        txtTarjeta.setText("");
        txtOrden.requestFocus(true);
    }
    
    public void sumatoria()
    {
        Float efectivo,tarjeta , propina,descuento,totalPagar,pagado;
        totalPagar = Float.valueOf(0);
        efectivo = Float.valueOf(0);
        tarjeta =Float.valueOf(0);
        propina =Float.valueOf(0);
        descuento =Float.valueOf(0);
        pagado = Float.valueOf(0);
        if(!"".equals(txtEfectivo.getText()))
            efectivo= Float.valueOf(txtEfectivo.getText());
        if(!"".equals(txtTarjeta.getText()))
            tarjeta = Float.valueOf(txtTarjeta.getText());
        if(!"".equals(txtPropina.getText()))
            propina = Float.valueOf(txtPropina.getText());
        if(!"".equals(txtDescuento.getText()))
             descuento = Float.valueOf(txtDescuento.getText());
        if(!"".equals(txtPagar.getText()))
             totalPagar = Float.valueOf(txtPagar.getText());
        Float totalVuelto = efectivo - (totalPagar + propina - tarjeta -descuento);
        Float total= totalPagar+propina-descuento;
        if(totalVuelto <=0)
        {
            lbVuelto.setText("0.0");
             pagado= efectivo+tarjeta;
        }
        else
        {
            lbVuelto.setText(totalVuelto.toString());
            pagado= efectivo+tarjeta+descuento-totalVuelto;
        }
        lbPagado.setText(pagado.toString());
        if(descuento>0)
        {
        }
        if(total <= 0)
            lbTotal.setText("0.0");
        else
            lbTotal.setText(total.toString());
    }
    
    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        // TODO add your handling code here:
        if(obs!=null)
        obs.actualizar();
        this.setVisible(false);
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void txtOrdenKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtOrdenKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_txtOrdenKeyTyped

    private void txtPagarKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPagarKeyTyped
        // TODO add your handling code here:
        char c=evt.getKeyChar();  
        if((!Character.isDigit(c))&&(c != '.')) { 
              getToolkit().beep();                
              evt.consume(); 
          }
    }//GEN-LAST:event_txtPagarKeyTyped

    private void txtVoucherKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtVoucherKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_txtVoucherKeyTyped

    private void txtDescuentoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDescuentoKeyReleased
        // TODO add your handling code here:
        sumatoria();
    }//GEN-LAST:event_txtDescuentoKeyReleased

    private void txtDescuentoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDescuentoKeyTyped
        // TODO add your handling code here:
        char c=evt.getKeyChar();
        if((!Character.isDigit(c))&&(c != '.')) {
            getToolkit().beep();
            evt.consume();
        }
    }//GEN-LAST:event_txtDescuentoKeyTyped

    private void txtPropinaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPropinaKeyReleased
        // TODO add your handling code here:
        sumatoria();
    }//GEN-LAST:event_txtPropinaKeyReleased

    private void txtPropinaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPropinaKeyTyped
        // TODO add your handling code here:
        char c=evt.getKeyChar();
        if((!Character.isDigit(c))&&(c != '.')) {
            getToolkit().beep();
            evt.consume();
        }
    }//GEN-LAST:event_txtPropinaKeyTyped

    private void txtTarjetaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTarjetaKeyReleased
        // TODO add your handling code here:
        sumatoria();
    }//GEN-LAST:event_txtTarjetaKeyReleased

    private void txtTarjetaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTarjetaKeyTyped
        // TODO add your handling code here:
        char c=evt.getKeyChar();
        if((!Character.isDigit(c))&&(c != '.')) {
            getToolkit().beep();
            evt.consume();
        }
    }//GEN-LAST:event_txtTarjetaKeyTyped

    private void txtEfectivoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEfectivoKeyReleased
        // TODO add your handling code here:
        sumatoria();
    }//GEN-LAST:event_txtEfectivoKeyReleased

    private void txtEfectivoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEfectivoKeyTyped
        // TODO add your handling code here:
        char c=evt.getKeyChar();
        if((!Character.isDigit(c))&&(c != '.')) {
            getToolkit().beep();
            evt.consume();
        }

    }//GEN-LAST:event_txtEfectivoKeyTyped

    private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosing
        // TODO add your handling code here:
        if(obs!=null)
            obs.actualizar();
    }//GEN-LAST:event_formInternalFrameClosing

    private void jCheckBox2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox2StateChanged
        // TODO add your handling code here:
        int y=0;
        if(jCheckBox2.isSelected())
        {
            float x= Float.parseFloat(txtPagar.getText());
            y=(int) (x*0.05);
            txtPropina.setText(String.valueOf(y));
        }
        else
            txtPropina.setText("");
        float total = Float.valueOf(txtPagar.getText());
        lbTotal.setText(String.valueOf(total+y));
    }//GEN-LAST:event_jCheckBox2StateChanged

    private void jCheckBox2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCheckBox2ItemStateChanged
        // TODO add your handling code here:
        
    }//GEN-LAST:event_jCheckBox2ItemStateChanged

    private void txtEfectivoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtEfectivoFocusGained
        // TODO add your handling code here:
        Object o = evt.getSource(); 
        if(o instanceof javax.swing.JTextField)
        { 
            javax.swing.JTextField txt = (javax.swing.JTextField) o; 
            txt.setSelectionStart(0); 
            txt.setSelectionEnd(txt.getText().length()); 
        }
    }//GEN-LAST:event_txtEfectivoFocusGained

    private void txtTarjetaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtTarjetaFocusGained
        // TODO add your handling code here:
        Object o = evt.getSource(); 
        if(o instanceof javax.swing.JTextField)
        { 
            javax.swing.JTextField txt = (javax.swing.JTextField) o; 
            txt.setSelectionStart(0); 
            txt.setSelectionEnd(txt.getText().length()); 
        }
    }//GEN-LAST:event_txtTarjetaFocusGained

    private void txtPropinaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPropinaFocusGained
        // TODO add your handling code here:
        Object o = evt.getSource(); 
        if(o instanceof javax.swing.JTextField)
        { 
            javax.swing.JTextField txt = (javax.swing.JTextField) o; 
            txt.setSelectionStart(0); 
            txt.setSelectionEnd(txt.getText().length()); 
        }
    }//GEN-LAST:event_txtPropinaFocusGained

    private void txtDescuentoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDescuentoFocusGained
        // TODO add your handling code here:
        Object o = evt.getSource(); 
        if(o instanceof javax.swing.JTextField)
        { 
            javax.swing.JTextField txt = (javax.swing.JTextField) o; 
            txt.setSelectionStart(0); 
            txt.setSelectionEnd(txt.getText().length()); 
        }
    }//GEN-LAST:event_txtDescuentoFocusGained

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JComboBox cmbMesa;
    private javax.swing.JComboBox cmbMesero;
    private com.toedter.calendar.JDateChooser fecha;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JLabel label;
    private javax.swing.JLabel lbPagado;
    private javax.swing.JLabel lbTotal;
    private javax.swing.JLabel lbVuelto;
    private entidad.Orden orden1;
    private javax.swing.JTextField txtDescuento;
    private javax.swing.JTextField txtEfectivo;
    private javax.swing.JTextField txtOrden;
    private javax.swing.JTextField txtPagar;
    private javax.swing.JTextField txtPropina;
    private javax.swing.JTextField txtTarjeta;
    private javax.swing.JTextField txtVoucher;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
